<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" isELIgnored="false"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Thêm tin trợ giúp</title>
<script type="text/javascript" charset="utf-8">
	$(function() {
		$("input.file_1").filestyle({
			image : "<spring:theme code='theme.admin'/>/imageForms/upload_file.gif",
			imageheight : 29,
			imagewidth : 78,
			width : 300
		});
	});
</script>
</head>
<body>
	<div id="page-heading">
		<h1>
			Quản lý tin trợ giúp
		</h1>
	</div>

	<!-- start id-form -->
	<form:form action="addSupportNews" commandName="supportNews" method="POST" id="addSupportNews" enctype="multipart/form-data">
		<input type="hidden" name="id" value="${supportNews.id }">
		<form:hidden path="url_image"/>
		<table border="0" cellpadding="0" cellspacing="0" id="id-form">
			<tr>
				<th valign="top">Tiêu đề</th>
				<td><input type="text" class="inp-form" name="title" value="${supportNews.title}"/></td>
				<td><form:errors path="title" cssClass="error"></form:errors></td>
			</tr>

			<tr>
				<th valign="top">Nội dung</th>
				<td>
				<textarea class="ckeditor" cols="80" value=""
					id="editor" rows="10" tabindex="1"></textarea>
				<input type="hidden" name="content" value="${supportNews.content}" id="contentSupportNews">
				</td>
				<td><form:errors path="content" cssClass="error"></form:errors></td>
			</tr>
			<tr>
				<th>Upload Ảnh:</th>
				<td style="width: 390px;"><form:input type="file" path="fileSupportNewsUpload" class="file_1" />
					<span style="padding-left: 100px;">JPG,PNG,JPEG,GIF. Tối đa là 2MB</span>
				</td>
				<td></td>
			</tr>
				<c:if test="${hasErrorUpload}">
				<tr>
					<th></th>
					<td><span class="error">${errorUpload}</span></td>
				</tr>
				</c:if>
			<tr>
				<th valign="top">Trạng thái:</th>
				<td>
					<form:radiobutton path="active" value="1" class=".inp-form-radio" /><label>Hiển thị</label> 
					<form:radiobutton path="active" value="0" class=".inp-form-radio" /><label>Không hiển thị</label>
				</td>
				<td><form:errors path="active" class="error" /></td>
			</tr>

			<tr>
				<th>&nbsp;</th>
				<td valign="top"><input type="button" onclick="saveSupportNews();"
					value="<spring:message code="button.save" />" class="form-submit" />
					<input type="button" onclick="window.location.href='manage-support-news'"
					value="<spring:message code="button.cancel" />" class="form-reset" /></td>
				<td></td>
			</tr>
		</table>
	</form:form>
	<script type="text/javascript">
		$(document).ready(function(){
			CKEDITOR.on('instanceReady', function(evt){
		        var editor = evt.editor;
		        setContent(editor);
		    });
		});
		
		function saveSupportNews() {
			var content = CKEDITOR.instances['editor'].getData();
			$("#contentSupportNews").val(content);
			$("#addSupportNews").submit();
		};

		function setContent(editor){
			var content = $('#contentSupportNews').val();
			editor.setData(content);
		};
	</script>
</body>
</html>